﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using GMS.BIZ;

namespace Web.SetSystem
{
    public partial class WebForm8 : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!((Account)HttpContext.Current.Session["Account"]).RoleCurrent.Equals('a')) Response.Redirect("Default.aspx");
            refreshCompany();
            refreshCompanystyle();
            refreshJoblist();
            refreshComputerlist();
            refreshEnglish();
        }

        protected void ImageButton_addcompany_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result1.Text = myLb.AddCompany(TextBox_companyname.Text.ToString());

            refreshCompany();
        }

        protected void ImageButton_delcompany_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result1.Text = myLb.DeleteCompany(TextBox_companyname.Text);
            refreshCompany();


        }

        protected void ImageButton_addcompstyle_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result2.Text = myLb.AddCompanyStyle(TextBox_compstyle.Text.ToString());

            refreshCompanystyle();
        }

        protected void refreshCompany()
        {
            ArrayList myAL = Library.GetCompanyLib();
            GridView_companylist.DataSource = myAL;
            GridView_companylist.DataBind();
        }

        protected void refreshCompanystyle()
        {
            ArrayList myAL = Library.GetCompanyStyleLib();
            GridView_companystyle.DataSource = myAL;
            GridView_companystyle.DataBind();
        }

        protected void refreshJoblist()
        {
            ArrayList myAL = Library.GetJobLib();
            GridView_job.DataSource = myAL;
            GridView_job.DataBind();
        }

        protected void refreshComputerlist()
        {
            ArrayList myAL = Library.GetComputerLib();
            GridView_computer.DataSource = myAL;
            GridView_computer.DataBind();
        }

        protected void refreshEnglish()
        {
            ArrayList myAL = Library.GetEnglishLib();
            GridView_englishlib.DataSource = myAL;
            GridView_englishlib.DataBind();
        }

        protected void ImageButton_delcompstyle_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result2.Text = myLb.DeleteCompanyStyle(TextBox_compstyle.Text.ToString());

            refreshCompanystyle();
        }

        protected void ImageButton_addjob_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result3.Text = myLb.AddJob(TextBox_jobname.Text.ToString());

            refreshJoblist();
        }

        protected void ImageButton_deljob_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result3.Text = myLb.DeleteJob(TextBox_jobname.Text.ToString());

            refreshJoblist();
        }

        protected void ImageButton_addcomputer_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result4.Text = myLb.AddComputer(TextBox_computername.Text.ToString());

            refreshComputerlist();
        }

        protected void ImageButton_delcomputer_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result4.Text = myLb.DeleteComputer(TextBox_computername.Text.ToString());

            refreshComputerlist();
        }

        protected void GridView_companylist_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_companylist.PageIndex = e.NewPageIndex;
            refreshCompany();
        }

        protected void GridView_companystyle_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_companystyle.PageIndex = e.NewPageIndex;
            refreshCompanystyle();
        }

        protected void GridView_job_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_job.PageIndex = e.NewPageIndex;
            refreshJoblist();
        }

        protected void GridView_computer_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_computer.PageIndex = e.NewPageIndex;
            refreshComputerlist();
        }

        protected void ImageButton_addenglish_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result5.Text = myLb.AddEnglish(TextBox_englishname.Text);
        }

        protected void ImageButton_delenglish_Click(object sender, ImageClickEventArgs e)
        {
            Library myLb = new Library();
            Label_result5.Text = myLb.DeleteEnglish(TextBox_englishname.Text);
        }

        protected void GridView_englishlib_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_englishlib.PageIndex = e.NewPageIndex;

            refreshEnglish();
        }
    }
}
